package com.wn.servlet;

import com.wn.bean.User;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @author yellow Docter
 * @date 2022 -07-05
 * @desc
 */
@WebServlet("/logout")
public class LogoutServlet extends javax.servlet.http.HttpServlet {

    protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
        this.doGet(request, response);
    }

    protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {

        HttpSession session = request.getSession();
        //把session中的存储的 user清空
//        session.setAttribute("user",null);
        session.removeAttribute("user");

        //销毁session
//        session.invalidate();
        request.getRequestDispatcher("/index.jsp").forward(request,response);
    }
}
